/*
 * Messaging.h
 *
 *  Created on: 19.11.2012
 *      Author: Michael
 */

#ifndef TTC_H_
#define TTC_H_

#include "rodos.h"
#include "hal_uart.h"

#include "global.h"

#include "../Messaging/protocol.h"
#include "../hardware.h"

#define BAUDRATE		115200
#define BUFFERSIZE		128

enum stateReceive {
	DEFAULT = -1,
	START1 = 0,
	START2,
	START3,
	START4,
	END
};

class TTC: public Thread {
public:
	TTC(const char* name, const long prio);
	virtual ~TTC();
	void init();
	void run();

private:
	char buffer[BUFFERSIZE];
	float values[23];

	void receiveCommand();
	void sendTelemetry();
	void sendPayload();
	int parseMsg(char* buffer, int readCnt, int* frameLength, msgTypes* msgType);

	void Float2Char(char* buf, float in);
	float Char2Float(char* buf);
	void sendChar(char ch);
};

#endif /* TTC_H_ */
